import json

from home.models import Article


def common_not(request):
    tay = Article.objects.order_by('-total_views')[0:9]
    # 最新文章
    nwe = Article.objects.order_by('-created')[0:2]
    print(request.COOKIES.get('login_name'))
    if 'login_name' in request.COOKIES:
        username = request.COOKIES.get('login_name')
        try:
            username = json.loads(username)
        except Exception:
            pass
    else:
        username = ''
    return {'tay':tay,'nwe':nwe,'username':username}
